package com.ssm.dao;

import com.ssm.domain.Permission;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface IPermissionDao {

    @Select("select * from permission where id in (select permissionId from role_permission where roleId =  #{roleId})")
    List<Permission> findPermissionByRoleId(String roleId) throws Exception;

    @Select("select * from permission")
    List<Permission> findAll();

    @Select("select * from permission where id = #{permissionId}")
    Permission findById(String permissionId);

    @Insert("insert into role_permission values(#{permissionId}, #{roleId})")
    void save(@Param("permissionId") String permissionId, @Param("roleId") String roleId);
}
